// ----------------------------------------------------------------------------
// diabindException.cpp
// Exception object
// ----------------------------------------------------------------------------


#include "stdafx.h"
#include "diabindException.h"


// ----------------------------------------------------------------------------

namespace diabind
{

// ----------------------------------------------------------------------------

CException::CException(HRESULT hResult, const char *szFunctionName)
    : CBase(szFunctionName)
    , m_hResult(hResult)
{
}

// ----------------------------------------------------------------------------

HRESULT CException::GetResult() const
{
    return m_hResult;
}

// ----------------------------------------------------------------------------

std::string CException::GetDescription() const
{
    std::stringstream Stream;
    Stream << "Call " << what() << " failed, HRESULT=0x" << std::hex << m_hResult;
    return Stream.str();
}

// ----------------------------------------------------------------------------

CPyException::CPyException(PyObject *pType, const char *szDesc)
    : CBase(szDesc)
    , m_pType(pType)
{
}

// ----------------------------------------------------------------------------

void CPyException::Translate(CPyException const& Exception)
{
    PyErr_SetString(Exception.m_pType, Exception.what());
}

// ----------------------------------------------------------------------------

}   // namespace diabind

// ----------------------------------------------------------------------------
